<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1. 具名函数(和鸿蒙中一样)
        function sayHi(name, food) {
            console.log('好好')
            console.log(name, food)
        }
        sayHi('gg', 'egg')

        // 2. 匿名函数(鸿蒙不允许这么写)
        const func = function(name, food) {
            console.log(name, food)
        }
        func('aa', 'eggs')

        // 3.箭头函数(和鸿蒙中一样)
        const func2 = (name, food) => {
            console.log(name, food)
        }
        func2('bb', 'hanboge')

        // 4. 剩余参数, 参数默认值
        // 剩余参数必须是最后一个
        function eatFood(f1, f2 = '剁椒鱼头', ...foods) {
            console.log(f1, f2)
            console.log(foods)
        }
        eatFood('xilan', 'jidan', 'liulianpaigutang')
        eatFood('西兰花')
    </script>
</body>
</html>